/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package thelife;

/**
 *
 * @author Sebek
 */
public class Cell extends Thread {

    Matrix m;
    int i, j;

    public Cell(Matrix m, int i, int j) {
        this.m = m;
        this.i = i;
        this.j = j;
    }

    @Override
    public void run() {
        if (m.present[i][j]) {
            if (m.livingNeighbours(i, j) == 2 || m.livingNeighbours(i, j) == 3) {
                m.future[i][j] = true;
            } else {
                m.future[i][j] = false;
            }
        } else {
            if (m.livingNeighbours(i, j) == 3) {
                m.future[i][j] = true;
            } else {
                m.future[i][j] = false;
            }
        }
    }
}
